package com.ruoyi.safe.controller.web;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.safe.domain.vo.BizSafeDocAttachVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.safe.domain.BizSafeDocAttach;
import com.ruoyi.safe.service.IBizSafeDocAttachService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 安全资料文件Controller
 * 
 * @author ruoyi
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/safeDoc/safeDoc")
public class BizSafeDocAttachController extends BaseController
{
    @Autowired
    private IBizSafeDocAttachService bizSafeDocAttachService;

    /**
     * 查询安全资料文件列表
     */
    @PreAuthorize("@ss.hasPermi('safeDoc:safeDoc:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizSafeDocAttach bizSafeDocAttach)
    {
        startPage();
        List<BizSafeDocAttachVO> list = bizSafeDocAttachService.selectBizSafeDocAttachList(bizSafeDocAttach);
        return getDataTable(list);
    }

    /**
     * 导出安全资料文件列表
     */
    @PreAuthorize("@ss.hasPermi('safeDoc:safeDoc:export')")
    @Log(title = "安全资料文件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizSafeDocAttach bizSafeDocAttach)
    {
        List<BizSafeDocAttachVO> list = bizSafeDocAttachService.selectBizSafeDocAttachList(bizSafeDocAttach);
        ExcelUtil<BizSafeDocAttachVO> util = new ExcelUtil<BizSafeDocAttachVO>(BizSafeDocAttachVO.class);
        util.exportExcel(response, list, "安全资料文件数据");
    }

    /**
     * 获取安全资料文件详细信息
     */
    @PreAuthorize("@ss.hasPermi('safeDoc:safeDoc:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizSafeDocAttachService.selectBizSafeDocAttachById(id));
    }

    /**
     * 新增安全资料文件
     */
    @PreAuthorize("@ss.hasPermi('safeDoc:safeDoc:add')")
    @Log(title = "安全资料文件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizSafeDocAttach bizSafeDocAttach)
    {
        return toAjax(bizSafeDocAttachService.insertBizSafeDocAttach(bizSafeDocAttach));
    }

    /**
     * 修改安全资料文件
     */
    @PreAuthorize("@ss.hasPermi('safeDoc:safeDoc:edit')")
    @Log(title = "安全资料文件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizSafeDocAttach bizSafeDocAttach)
    {
        return toAjax(bizSafeDocAttachService.updateBizSafeDocAttach(bizSafeDocAttach));
    }

    /**
     * 删除安全资料文件
     */
    @PreAuthorize("@ss.hasPermi('safeDoc:safeDoc:remove')")
    @Log(title = "安全资料文件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizSafeDocAttachService.deleteBizSafeDocAttachByIds(ids));
    }
}
